//
//  NSLayoutConstraint+CAIIBAdapter.m
//  MerchantBusinessClient
//
//  Created by simon on 2021/7/8.
//  Copyright © 2021 com.Chs. All rights reserved.
//

#import "NSLayoutConstraint+CAIIBAdapter.h"
#import <Objc/runtime.h>


@implementation NSLayoutConstraint (CHSIBAdapter)


- (void)setShouldAdapterScreenWidth:(BOOL)shouldAdapterScreenWidth {
    
    if (shouldAdapterScreenWidth) {
        CGFloat deviceScaleWidthFit = [[UIScreen mainScreen] bounds].size.width / 375.0;
        self.constant = self.constant * deviceScaleWidthFit;
    }
    objc_setAssociatedObject(self, @selector(shouldAdapterScreenWidth), @(shouldAdapterScreenWidth), OBJC_ASSOCIATION_ASSIGN);
}

- (BOOL)shouldAdapterScreenWidth{
    return [objc_getAssociatedObject(self, _cmd) boolValue];
}

@end
